type ABC enum {
     type A;
     type B;
     type C;
};
const A: ABC { |ABC| { |A| () } };
const B: ABC { |ABC| { |B| () } };
const C: ABC { |ABC| { |C| () } };

function parse-abc:
    &(String) => ABC
    &(str) =>
        if (str = 'A'):
            A,
        elif (str = 'B'):
            B,
        elif (str = 'C'):
            C,
        else:
            { panic 'invalid ABC' };

function String:
    &(ABC) => String
	&(x) =>
        switch x:
	       case A: 'A',
	       case B: 'B',
	       case C: 'C',
        end;

function f:
	&(ABC,ABC) => ABC
	&(x,y) =>
        select (x,y):
	       case (A,A): A,
	       case (A,B): C,
	       case (A,C): B,
	       case (B,A),(B,B),(B,C): B,
	       case (C,A): B,
	       case (C,B): A,
	       case (C,C): C,
        end;

entry { crash-on-error
    \ await let x-str := { sys::scanln '' },
    \ await let y-str := { sys::scanln '' },
    let x := { parse-abc x-str },
    let y := { parse-abc y-str },
    let z := { f (x, y) },
    { sys::println z.{String} }
};


